class CustomRequest {
    constructor(baseUrl = '') {
        this.baseUrl = baseUrl
    }
    /**
     * @description request方法
     * @param {*} options 
     */
    request(options) {
        const { url = '' } = options;
        const baseUrl = this.baseUrl;
        return new Promise((resolve, reject) => {
            wx.request({
                ...options,
                url: baseUrl ? baseUrl + url : url,
                success: (res) => void resolve(res.data),
                fail: reject
            })
        })
    }
    get(options) {
        return this.request({ ...options, method: "GET" })
    }

    post(options) {
        return this.request({ ...options, method: "POST" })
    }
}

const requestInstance = new CustomRequest()

module.exports = requestInstance